<?php
namespace app\admin\controller;

use app\BaseController;
use think\facade\View;
use think\facade\Request;
use think\facade\Db;


class Index extends BaseController
{
    public function index()
    {
        // 模板输出
        return View::fetch('goog');
       // return '<style type="text/css">*{ padding: 0; margin: 0; } div{ padding: 4px 48px;} a{color:#2E5CD5;cursor: pointer;text-decoration: none} a:hover{text-decoration:underline; } body{ background: #fff; font-family: "Century Gothic","Microsoft yahei"; color: #333;font-size:18px;} h1{ font-size: 100px; font-weight: normal; margin-bottom: 12px; } p{ line-height: 1.6em; font-size: 42px }</style><div style="padding: 24px 48px;"> <h1>:) </h1><p> ThinkPHP V' . \think\facade\App::version() . '<br/><span style="font-size:30px;">14载初心不改 - 你值得信赖的PHP框架</span></p><span style="font-size:25px;">[ V6.0 版本由 <a href="https://www.yisu.com/" target="yisu">亿速云</a> 独家赞助发布 ]</span></div><script type="text/javascript" src="https://tajs.qq.com/stats?sId=64890268" charset="UTF-8"></script><script type="text/javascript" src="https://e.topthink.com/Public/static/client.js"></script><think id="ee9b1aa918103c4fc"></think>';
    }

   

    // 获得分类
    public function getfen()
    {
      
       // pid 要从0开始 从1开始有冲突 查询出分类并组装有三级分类数据
       $res= Db::name('fen')->where('pid',0)->select()->toArray();
       // 然后查留二级数据
       $nuber=count($res);
       for ($x=0; $x<$nuber; $x++) {
        // 查出二级分类
       $id=$res[$x]['id'];
       $list= Db::name('fen')->where('pid',$id)->select()->toArray();
       // 二级三分组成一个数据
       $nuber2=count($list);
       for ($i=0; $i<$nuber2; $i++) {
           $id2=$list[$i]['id'];
           // 三级分类数据
           $data= Db::name('fen')->where('pid',$id2)->select()->toArray();
           if($data){
            $list[$i]['list']=$data;
           }
           
       }
       if($list){
        $res[$x]['list']=$list;
       }
      
      } 

      return json($res);
      // print_r($res);

    }

   

    

}
